//
//  CUseHttpTool.m
//  FaceTo
//
//  Created by chijia on 2017/7/15.
//  Copyright © 2017年 chengbangming. All rights reserved.
//

#import "CUseHttpTool.h"
#import "ErrorInfo.h"
#import "MJExtension.h"


@implementation CUseHttpTool
/** 商家列表请求 */
+ (void)getShopListSuccess:(void (^) (ShopModel * model))success failure:(void(^)(NSError * error))failure{
    NSString * url = [NSString stringWithFormat:@"http://101.132.41.114:8080/miandui/shop_list_get/"];
    LogUrl;
    [FacetoCbmHttp post:url params:nil success:^(id responseObj) {
        
        ShopModel * model = [ShopModel mj_objectWithKeyValues:responseObj];
//        if(![model.code isEqualToString:@"200"]){
//            
//        }
        if(success){
            success(model);
        }
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
        if(failure){
            failure(error);
        }
    }];
}
/** 登陆 */
+ (void)loginWithidentification:(NSString *)identification password:(NSString *)password Success:(void (^) (loginModel * model))success failure:(void(^)(NSError * error))failure{
    NSString * url = [NSString stringWithFormat:@"http://101.132.41.114:8080/miandui/login/"];
    LogUrl;
    NSString  *urlString1 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSDictionary * params = @{
                              @"identification" : identification,      // 手机号码
                              @"password"  : password       // 密码
                              };
    [FacetoCbmHttp post:urlString1 params:params success:^(id responseObj) {
        loginModel * model = [loginModel mj_objectWithKeyValues:responseObj];
        if(success){
            success(model);
        }
    } failure:^(NSError *error) {
        if(failure){
            failure(error);
            NSLog(@"%@",error);
        }
    }];
}
/** 获取验证码 */
+ (void)getphoneCodeWithidentification:(NSString *)identification Success:(void (^) (SysModel * model))success failure:(void(^)(NSError * error))failure{
    NSString * url = [NSString stringWithFormat:@"http://dd8206f5.ngrok.io/miandui/vertification/"];
    LogUrl;
    NSDictionary * params = @{
                              @"identification" : identification      // 手机号码
                              };
    [FacetoCbmHttp post:url params:params success:^(id responseObj) {
        SysModel * model = [SysModel mj_objectWithKeyValues:responseObj];
        if(success){
            success(model);
        }
    } failure:^(NSError *error) {
        if(failure){
            failure(error);
        }
    }];
}
/** 注册 */
+ (void)registerWithidentification:(NSString *)identification password:(NSString *)password code:(NSString *)code Success:(void (^) (loginModel * model))success failure:(void(^)(NSError * error))failure{
    NSString * url = [NSString stringWithFormat:@"http://dd8206f5.ngrok.io/miandui/register/"];
    LogUrl;
    NSDictionary * params = @{
                              @"identification" : identification,      // 手机号码
                              @"password"  : password,
                              @"code"  : code
                              };
    [FacetoCbmHttp post:url params:params success:^(id responseObj) {
        loginModel * model = [loginModel mj_objectWithKeyValues:responseObj];
        if(success){
            success(model);
        }
    } failure:^(NSError *error) {
        if(failure){
            failure(error);
        }
    }];
    
}
@end
